package com.company.ThreadDemo;

public class StopDemo implements Runnable{
    private boolean flag = true;
    public void stop(){
        this.flag = false;
    }
    @Override
    public void run() {
        int x = 0;
        while(flag){
            System.out.println(x+++"sdadasdasdasd");
        }
    }
    public static void main(String[] args) throws InterruptedException {
        StopDemo stopDemo = new StopDemo();
        new Thread(stopDemo).start();
        for(int i =0;i<900;i++){
            Thread.sleep(1);
            if(i==800) {
                stopDemo.stop();
            }
        }
    }
}
